package com.xm.xmapp.customview;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.xm.xmapp.R;

public class MyDialog1 extends Dialog {

	private Context context;
	private String title_str;
	private String content_str;
	private String queding_str;

	public MyDialog1(Context context, String title, String content,
			String queding) {
		super(context, R.style.Dialog);
		// TODO Auto-generated constructor stub
		this.context = context;
		this.title_str = title;
		this.content_str = content;
		this.queding_str = queding;

	}

	@SuppressLint("InflateParams")
	public void init() {
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.dialog_tip_one, null);
		TextView title = (TextView) view.findViewById(R.id.title);
		TextView content = (TextView) view.findViewById(R.id.content);

		TextView queding = (TextView) view.findViewById(R.id.queding);

		queding.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				MyDialog1.this.dismiss();
			}
		});
		if (queding_str != null)
			queding.setText(queding_str);

		title.setText(title_str == null ? "" : title_str);
		content.setText(content_str == null ? "" : content_str);

		setContentView(view);

		Window dialogWindow = getWindow();
		WindowManager.LayoutParams lp = dialogWindow.getAttributes();
		DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
		lp.width = (int) (d.widthPixels * 0.8); // 高度设置为屏幕的0.6
		dialogWindow.setAttributes(lp);

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		init();

	}
}
